<?php
namespace app\user\event\subscribes\user\admin;

use app\admin\logic\system\Log;
use think\Event;

class Teacher
{
    public function subscribe(Event $event)
    {
        /** 新建 */
        $event->listen('TeacherCreated', function ($teacher) {
            $teacher_name = $teacher->user()->where('id', $teacher->user_id)->value('nick_name');
            Log::write('讲师【' . $teacher_name . '】', 'teacher', 'create');
        });
        /** 更新 */
        $event->listen('TeacherUpdated', function ($teacher) {
            $teacher_name = $teacher->user()->where('id', $teacher->user_id)->value('nick_name');
            Log::write('讲师【' . $teacher_name . '】的信息', 'teacher', 'update');
        });
        /** 删除 */
        $event->listen('TeacherDeleted', function ($teacher) {
            $teacher_name = $teacher->user()->where('id', $teacher->user_id)->value('nick_name');
            Log::write('讲师【' . $teacher_name . '】', 'teacher', 'delete');
        });

    }
}
